<!DOCTYPE html>
<html>
<head>
<base href="${basePath}">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>预约订座</title>
$!{include("schedule_list_js_css.html")}
</head>
<body>
<!--#var(ClassScheduleModel schedule, List<ClassScheduleModel> csmList)-->
<ul id="stat_info" class="nav nav-tabs" style="padding-left: 2px; padding-top: 2px;">
<!-- #if(type==0) -->
<li class="active"><a href="${basePath}weixin/scheduleListByDate.jhtml?memberId=${memberId}&clazzId=${clazzId}">今日预定课程</a></li>
<li><a href="${basePath}weixin/scheduleListByDate.jhtml?memberId=${memberId}&clazzId=${clazzId}&type=mr">明日预定课程</a></li>
<!-- #else -->
<li><a href="${basePath}weixin/scheduleListByDate.jhtml?memberId=${memberId}&clazzId=${clazzId}">今日预定课程</a></li>
<li class="active"><a href="${basePath}weixin/scheduleListByDate.jhtml?memberId=${memberId}&clazzId=${clazzId}&type=mr">明日预定课程</a></li>
<!-- #end -->
</ul><input type="hidden" id="hidMemberId" value="${memberId}">
<table id="tb_members" class="table table-bordered table-hover table-condensed" style="text-align: center; width:100%;">
	<tr class="tr-edit">
		<td width="100px">时段</td>
		<td width="150px">课程</td>
		<td width="70px">操作</td>
	</tr>
	<!--#foreach(schedule in csmList)-->
	<!-- #if(schedule.ydzt=='接受预定') -->
		<tr>
	<!-- #else -->
		<tr style="background: #f0f0f0;">
	<!-- #end -->
		<td class="table-edit" style="text-align:left;">${schedule.ksjs}</td>
		<td class="table-edit"  style="text-align:left;">${schedule.kcmc} ${schedule.hyrs}</td>
		<td id="trId${schedule.kcxh}" style="cursor:pointer;text-align:left;" class="table-edit">
		<!-- #if(schedule.ydzt=='接受预定') -->
			<!-- #if(schedule.ydbh=="false") -->
			<a href="javascript:void(0);" onclick="resvTodaySchedule(${schedule.kcxh})">预定</a>
			<!-- #else -->
			<a href="javascript:void(0);" onclick="cancelTodaySchedule(${schedule.kcxh})">取消预定</a>
			<!-- #end -->
		<!-- #end -->
		</td>
	<tr>
	<!--#end-->
</table>
<script type="text/javascript">
//--取消今天的课程
function cancelTodaySchedule(kcxh) {
	var memberId = $("#hidMemberId").val();
	var url = "${basePath}/weixin/ajaxCancelSchedule.jhtml";
	$.post(url, {
		scheduleId : kcxh,
		memberId : memberId
	}, function(resp) {
		var data = eval("(" + resp + ")");
		if (data.success) {
			$("#trId"+kcxh).html("<a href=\"javascript:void(0);\"  onclick=\"resvTodaySchedule("+kcxh+")\">预定</a>");
			var d = alert(data.msg);
			setTimeout(function() {
				d.close().remove();
			}, 900);
		} else {
			error("取消预约失败!");
		}
	});
}

//--预定课程
function resvTodaySchedule(scheId) {
	if (!scheId || scheId == 'undefined') {
		var d = alert("课程还未开启预定!");
		setTimeout(function() {
			d.close().remove();
		}, 900);
		return;
	}
	var memberId = $("#hidMemberId").val();
	var url = "${basePath}/weixin/ajaxResvSchedule.jhtml";
	$.post(url, {
		scheId : scheId,
		memberId : memberId
	}, function(resp) {
		var data = eval("(" + resp + ")");
		if (data.success) {
			$("#trId"+scheId).html("<a href=\"javascript:void(0);\"  onclick=\"cancelTodaySchedule("+scheId+")\">取消预定</a>");
			var d = alert(data.msg);
			setTimeout(function() {
				d.close().remove();
			}, 900);
		} else {
			error(data.msg);
		}
	});
}

</script>
</body>
</html>